<div id="divAddGroup">
    <?php echo View::factory('admin/common/breadcrumbs')->set('breadcrumbs', $breadcrumbs)->render(); ?>

    <div class="page-content">
        <div class="page-header">
            <h1>
                List Group     
            </h1>
        </div>
        <?php echo View::factory('admin/common/messege')->render(); ?>
        <div class="row">
            <div class="col-xs-12">
                <!-- PAGE CONTENT BEGINS -->
                <div class="row-fluid">
                    <div class="span12">
                        <div class="widget-box">
                            <div class="widget-header widget-header-blue widget-header-flat">

                                <p style="padding: 300px;font-size: 21px;">Create New Group Permission <span style="font-weight: bold;color: black"></span></p>

                            </div>

                            <div class="widget-body">
                                <div class="widget-main">
                                    <div class="step-content row-fluid position-relative" id="step-container">
                                        <form class="form-horizontal" id="validation-form" method="post">
                            

                                            <div class="form-group">
                                                <label class="control-label col-xs-12 col-sm-3 no-padding-right" >Name <span class="red">*</span>:</label>

                                                <div class="col-xs-12 col-sm-9">
                                                    <div class="clearfix">
                                                        <input type="text" id="namegroup" name="namegroup" class="col-xs-12 col-sm-5" value="" />
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="space-2"></div>

                                            <div class="form-group">
                                                <label class="control-label col-xs-12 col-sm-3 no-padding-right" >Description <span class="red">*</span>:</label>

                                                <div class="col-xs-12 col-sm-9">
                                                    <div class="clearfix">
                                                        <input type="text" id="description" name="description" class="col-xs-12 col-sm-5" value="" />
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="space-2"></div>
                                            
                                            <div class="space-2"></div>
                                            <div class="control-group">
                                                 <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="permission">Permission <span class="red">*</span>:</label>
                                                
                                                 <div class="controls" style="margin-left: 280px;padding: 10px 0;">
                                                    <select id='permission_id' name="permission_id[]" multiple='multiple'>
                                                        <?php
                                                        if (!empty($a_p_controller[0])) {
                                                            foreach ($a_p_controller as $o_pc) {
                                                                $o_emtity_pc = $o_pc->get_data();
                                                                $s_per = $o_emtity_pc->get_Permission();
                                                                $a_data_per = $s_per->query_all();
                                                                ?>
                                                                <optgroup label='<?= $o_emtity_pc->getDescription() ?>'>
                                                                    <?php
                                                                    if (!empty($a_data_per[0])) {
                                                                        foreach ($a_data_per as $o_data_per) {
                                                                            $o_entity_per = $o_data_per->get_data();
                                                                            $selected = "";
                                                                            if (isset($a_post['permission_id']) && is_array($a_post['permission_id']) && in_array($o_entity_per->getId(), $a_post['permission_id'])) {
                                                                                $selected = "selected";
                                                                            }
                                                                            echo "<option $selected value='" . $o_entity_per->getId() . "'>" . $o_entity_per->getDescription() . "</option>";
                                                                        }
                                                                    }
                                                                    ?>
                                                                </optgroup>
                                                                <?php }
                                                            }
                                                            ?>
                                                    </select>
                                                </div>
                                                <div class="controls" style="margin-left: 272px;padding: 10px 0;">
                                                        <?= Form::input('selectall', 'Select All', array('type' => 'button', 'id' => 'selectallper', 'class' => 'btn tip-bottom')) ?>
                                                        <?= Form::input('deselectall', 'Deselect All', array('type' => 'button', 'id' => 'deselectallper', 'class' => 'btn tip-bottom')) ?>
                                                </div>
                                            </div>
                                            <div class="space-8"></div>              
                                        </form>
                                    </div>
                                    <hr />
                                    <div class="row-fluid wizard-actions">
                                        <button id="cmdCancelAddGroup" class="btn btn-prev">
                                            <i class="icon-arrow-left"></i>
                                            Cancel
                                        </button>

                                        <button id="cmdsavegroup" class="btn btn-success btn-next" data-last="Finish ">
                                            Submit
                                            <i class="icon-arrow-right icon-on-right"></i>
                                        </button>
                                        <img id="loading" style="display: none;" src="<?= $url_base_theme . '/img/loading_1.gif' ?>" />
                                    </div>
                                </div><!-- /widget-main -->
                            </div><!-- /widget-body -->
                        </div>
                    </div>
                </div>
                <!-- PAGE CONTENT ENDS -->
            </div><!-- /.col -->
        </div><!-- /.row -->
        <div id="modal-delete" class="modal fade" tabindex="-1">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header no-padding">
                        <div class="table-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                <span class="white">&times;</span>
                            </button>
                            Delete
                        </div>
                    </div>

                    <div class="modal-body no-padding">
                        <div style="padding: 20px;">
                            Are you sure delete this user?
                        </div>
                    </div>

                    <div class="modal-footer no-margin-top">
                        <button type="button" class="btn btn-sm pull-right" data-dismiss="modal">
                            <i class="icon-remove"></i>
                            Close
                        </button>
                        <div class="pull-right">
                            &nbsp;
                        </div>
                        <button type="button" class="btn btn-sm btn-danger pull-right" id="cmdDelete">
                            <i class="icon-remove"></i>
                            Delete
                        </button>
                    </div>
                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </div><!-- PAGE CONTENT ENDS -->
    </div>
</div>

<script>
    var _group_add = group_add.CreateObject({
        id: '_group_add',
        full_url: '<?= Controller_Helper_Url::full_url() ?>'
    });
</script>
